<template>
  <div class="mod-service-notifyTemplate">
    <!-- 搜索栏 -->
    <div class="search-bar">
      <el-form
        @submit.native.prevent
        :inline="true"
        class="search-form"
        ref="searchForm"
        :model="searchForm"
        size="small"
      >
        <div class="input-row">
          <el-form-item
            :label="$t('platform.msgType') + ':'"
            class="search-form-item"
          >
            <el-select
              v-model="searchForm.messageType"
              :placeholder="$t('platform.msgType')"
              class="el-form-item"
              size="small"
            >
              <el-option label="店铺审核" :value="1"></el-option>
              <el-option label="商品审核" :value="2"></el-option>
              <el-option label="轮播图审核" :value="3"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item
            :label="$t('outlet.outletName') + ':'"
            class="search-form-item"
          >
            <el-input
              type="text"
              v-model="searchForm.shopAppName"
              :placeholder="$t('outlet.outletName')"
            ></el-input>
          </el-form-item>
          <el-form-item style="float: right">
            <div class="default-btn primary-btn" @click="searchChange(true)">
              {{ $t("crud.searchBtn") }}
            </div>
            <div class="default-btn" @click="resetSearchForm('searchForm')">
              {{ $t("product.reset") }}
            </div>
          </el-form-item>
        </div>
      </el-form>
    </div>

    <div class="main-container">
      <div class="table-con notice-table">
        <el-table
          ref="customizeNotifyTable"
          :data="dataList"
          header-cell-class-name="table-header"
          row-class-name="table-row-low"
          style="width: 100%"
        >
          <el-table-column
            :label="$t('formData.serialNumber')"
            type="index"
            width="80"
          >
          </el-table-column>
          <el-table-column
            align="center"
            :label="$t('platform.msgType')"
            prop="templateTypes"
          >
            <template slot-scope="scope">
              {{
                ["", "店铺审核", "商品审核", "轮播图审核"][
                  scope.row.messageType
                ]
              }}
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            :label="$t('outlet.outletName')"
            prop="shopAppName"
          >
          </el-table-column>
          <el-table-column
            align="center"
            :label="$t('brand.applicationTime')"
            prop="createTime"
          >
          </el-table-column>
          <el-table-column
            :label="$t('chat.read') + '/' + $t('chat.unRead')"
            prop="createTime"
            align="center"
          >
            <template slot-scope="scope"
              >{{ [$t("chat.unRead"), $t("chat.read")][scope.row.isCheck] }}
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            :label="$t('publics.operating')"
            fixed="right"
          >
            <template slot-scope="scope">
              <div class="text-btn-con">
                <div class="default-btn text-btn" @click="toNewInfo(scope.row)">
                  {{ $t("order.seeDetails") }}
                </div>
              </div>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <el-pagination
        v-if="dataList.length"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="page.currentPage"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="page.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="page.total"
      ></el-pagination>
    </div>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        dataList: [],
        page: {
          total: 0, // 总页数
          currentPage: 1, // 当前页数
          pageSize: 10, // 每页显示多少条
        },
        searchForm: {
          messageType: "",
        }, // 搜索
        dataListLoading: false,
        addOrUpdateVisible: false,
      };
    },
    created() {
      this.getDataList();
    },
    mounted() {},
    methods: {
      getDataList(page) {
        this.dataListLoading = true;
        this.$http({
          url: this.$http.adornUrl("/platform/auditingMessage/list"),
          method: "get",
          params: this.$http.adornParams(
            Object.assign(
              {
                current: page == null ? this.page.currentPage : page.currentPage,
                size: page == null ? this.page.pageSize : page.pageSize,
              },
              this.searchForm
            )
          ),
        }).then(({ data }) => {
          this.dataList = data.records;
          this.page.total = data.total;
          this.dataListLoading = false;
        });
      },
      toNewInfo(row) {
        this.$http({
          url: this.$http.adornUrl(
            "/platform/auditingMessage/check?id=" + row.id
          ),
          method: "get",
        }).then(({ code }) => {
          if (code == "00000") {
            this.searchChange();
          }
        });
        let path = "";
        if (row.messageType == 1) {
          // 店铺审核 商品审核 轮播图审核
          path = "/platform-outlet/auditOutlet?tabValue=management";
        } else if (row.messageType == 2) {
          path = "/prod-prodList?prodBelongs=2";
        } else if (row.messageType == 3) {
          path = "/platform-indexImg?activeTabIndex=2";
        }
        this.$router.push({
          path,
        });
      },
      /**
       * 刷新回调
       */
      refreshChange() {
        this.getDataList(this.page);
      },
      searchChange() {
        this.getDataList(this.page);
      },
      /**
       * 重置表单
       * @param {String} formName 表单名称
       */
      resetSearchForm(formName) {
        this.$refs[formName].resetFields();
        this.searchForm = {};
        this.searchChange();
      },
      handleSizeChange(val) {
        this.page.pageSize = val;
        this.searchChange();
      },
      handleCurrentChange(val) {
        this.page.currentPage = val;
        this.searchChange();
      },
    },
  };
</script>
<style lang="scss" scoped>
  .mod-service-notifyTemplate {
  }
</style>
